package net.pm.core.entities.db;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import net.pm.core.entities.PMCommandEntity;

import com.fasterxml.jackson.annotation.JsonIgnore;


/**
 * The persistent class for the product database table.
 * 产品
 */
@Entity
@Table(name="product")
public class Product extends PMCommandEntity<Product>{
	/**
	 * 
	 */
	private static final long serialVersionUID = -1279929437883076685L;
	private Long id;
	private Date addTime;
	private String productNo;
	private Integer productNumber;
	private String productsNorms;
	private String productName;
	private String productDesc;
	private Short status;
	private Pmuser produceUser;
	private Pmuser pmuser;
	private List<Collarmaterial> productionmaterials;
	
	//产品状态:0生产中，1生产己完成
	public static final Short STATUS_PRODUCE = Short.valueOf("0").shortValue();
	public static final Short STATUS_FINISH = Short.valueOf("1").shortValue();
	
	private List<Materiallog> materiallogs;
	@Transient
    public List<Materiallog> getMateriallogs() {
		return materiallogs;
	}

	public void setMateriallogs(List<Materiallog> materiallogs) {
		this.materiallogs = materiallogs;
	}


	public Product() {
    }

    
	public Product(Long id) {
		super();
		this.id = id;
	}


	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(unique=true, nullable=false)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}


    @Temporal( TemporalType.TIMESTAMP)
	@Column(nullable=false)
	public Date getAddTime() {
		return this.addTime;
	}

	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}


	@Column(nullable=false, length=30)
	public String getProductNo() {
		return this.productNo;
	}

	public void setProductNo(String productNo) {
		this.productNo = productNo;
	}


	@Column(nullable=false)
	public Integer getProductNumber() {
		return this.productNumber;
	}

	public void setProductNumber(Integer productNumber) {
		this.productNumber = productNumber;
	}


	@Column(nullable=false, length=200)
	public String getProductsNorms() {
		return this.productsNorms;
	}

	public void setProductsNorms(String productsNorms) {
		this.productsNorms = productsNorms;
	}

	@Column(nullable=false, length=20)
	public String getProductName() {
		return productName;
	}
	
	public void setProductName(String productName) {
		this.productName = productName;
	}

	@Column
	public String getProductDesc() {
		return productDesc;
	}

	public void setProductDesc(String productDesc) {
		this.productDesc = productDesc;
	}

	@Column(nullable=false)
	public Short getStatus() {
		return this.status;
	}

	public void setStatus(Short status) {
		this.status = status;
	}
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="produceUserId", nullable=false)
	public Pmuser getProduceUser() {
		return produceUser;
	}


	public void setProduceUser(Pmuser produceUser) {
		this.produceUser = produceUser;
	}


	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="UserId", nullable=false)
	public Pmuser getPmuser() {
		return pmuser;
	}
	public void setPmuser(Pmuser pmuser) {
		this.pmuser = pmuser;
	}

	//bi-directional many-to-one association to Productionmaterial
	@OneToMany(mappedBy="product",fetch=FetchType.LAZY)
	@JsonIgnore
	public List<Collarmaterial> getProductionmaterials() {
		return this.productionmaterials;
	}

	public void setProductionmaterials(List<Collarmaterial> productionmaterials) {
		this.productionmaterials = productionmaterials;
	}
	
	@Override
	public int compareTo(Product o) {
		// TODO Auto-generated method stub
		return 0;
	}
	
}